package com.hemerasolutions.v2trainer.component.detail;


import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import com.hemerasolutions.v2trainer.component.BaseComponent;
import com.hemerasolutions.v2trainer.component.interfaces.detail.EquipmentDetailsCompInterface;
import com.hemerasolutions.v2trainer.component.interfaces.list.PhotosListCompInterface;
import com.hemerasolutions.v2trainer.component.interfaces.list.VideosListCompInterface;
import com.hemerasolutions.v2trainer.model.exercise.Equipment;


@Controller
@Component("equipmentDetailsComp")
@Scope("prototype")
public class EquipmentDetailsComp extends BaseComponent implements EquipmentDetailsCompInterface {

	private static final long serialVersionUID = 1L;

	private Equipment equipment;
	
	@Autowired
	private VideosListCompInterface videosListHandler;

	@Autowired
	private PhotosListCompInterface photosListHandler;
	
	
	public EquipmentDetailsComp(){
		super();
	}
	
	@Override
	@PostConstruct
	public void init(){
		super.init();
	}
	
	@Override
	public void refresh(){
		this.photosListHandler.setPhotoType(PhotosListCompInterface.EQUIPMENT_PHOTO);
		this.photosListHandler.setPhotos(this.equipment.getPhotos());
		this.videosListHandler.setVideoType(VideosListCompInterface.EXERCISE_VIDEO);
		this.videosListHandler.setVideos(this.equipment.getVideos());

		this.photosListHandler.refresh();
		this.videosListHandler.refresh();
	}


	@Override
	public Equipment getEquipment() {
		return equipment;
	}


	@Override
	public void setEquipment(Equipment equipment) {
		this.equipment = equipment;
	}


	@Override
	public VideosListCompInterface getVideosListHandler() {
		return videosListHandler;
	}


	@Override
	public void setVideosListHandler(VideosListCompInterface videosListHandler) {
		this.videosListHandler = videosListHandler;
	}


	@Override
	public PhotosListCompInterface getPhotosListHandler() {
		return photosListHandler;
	}


	@Override
	public void setPhotosListHandler(PhotosListCompInterface photosListHandler) {
		this.photosListHandler = photosListHandler;
	}

	
	
}
